package com.xbl.test2.configuration;

import lombok.extern.slf4j.Slf4j;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xbl
 * @Description
 * @date 2019/1/27
 */
@Configuration
@EnableSwagger2
@Slf4j
public class SwaggerConfiguration {

    @Bean
    public Docket swaggerSpringMvcPlugin() {
        log.error("swagger is started");
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Test2-api")
                .select()
                //Ignores controllers annotated with @CustomIgnore
                .apis(RequestHandlerSelectors.basePackage("com.xbl.test2.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("Test2中的Rest Api").version("1.0").build();
    }
}
